package newhiant.hianto2o.com.activity;

import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

import newhiant.hianto2o.com.BR;
import newhiant.hianto2o.com.R;
import newhiant.hianto2o.com.adapter.CommonAdapter;
import newhiant.hianto2o.com.databinding.ActivityListvViewUpdateBinding;
import newhiant.hianto2o.com.model.Member;

public class ListvViewUpdateActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityListvViewUpdateBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_listv_view_update);

        List<Member> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            // 3个网络图片1个本地图片，依次循环
            Member member = new Member("member" + i, (i & 0x03) < 3 ? "http://upload.jianshu.io/users/upload_avatars/966283/c35cf84af036.JPG?imageMogr2/auto-orient/strip|imageView2/1/w/240/h/240" : null);
            list.add(member);
        }

        // 创建Adapter。BR类似与R文件，存储变量名称
        CommonAdapter<Member> adapter = new CommonAdapter<>(this, list, R.layout.item_adapter_update, BR.member);
        binding.setCommonAdapter(adapter);

    }
}
